﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using CMP.ERP.Model;
using CMP.ERP.Helper;
using System.Data.SqlClient;

namespace CMP.ERP.DAL
{
    public class WareHoseDAL
    {
        /// <summary>
        /// 实例化SQLHelper对象
        /// </summary>
        SQLHelper p = new SQLHelper();
        /// <summary>
        /// 显示仓库信息
        /// </summary>
        /// <returns></returns>
        public DataTable WareHoseShow()
        {
            StringBuilder buil = new StringBuilder();
            buil.Append("Proc_WareHose");
            SqlParameter[] par = new SqlParameter[]{

            };
            return p.ExecDataTable_Proc(buil.ToString(), par);
        }
        /// <summary>
        /// 添加仓库信息
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public int AddWareHose(WareHose e)
        {
            string sql = string.Format("insert into WareHose(WareHose_Name,WareHose_Address,WareHose_People,WareHose_Phone,WareHose_Remark,Commodity_Url) values('{0}','{1}','{2}','{3}','{4}','{5}')", e.WareHose_Name, e.WareHose_Address, e.WareHose_People, e.WareHose_Phone, e.WareHose_Remark, e.Commodity_Url);
            return p.ExecNonquery(sql);
        }
        /// <summary>
        /// 根据仓库编码删除仓库信息
        /// </summary>
        /// <param name="Express_Company_Id">仓库编码</param>
        /// <returns></returns>
        public int DelWareHose(int WareHose_Id)
        {
            string sql = string.Format("delete from WareHose where WareHose_Id='{0}'", WareHose_Id);
            return p.ExecNonquery(sql);
        }
        /// <summary>
        /// 根据仓库编码查询仓库信息
        /// </summary>
        /// <param name="Express_Company_Id">仓库编码</param>
        /// <returns></returns>
        public DataTable GetWareHose(int WareHose_Id)
        {
            string sql = string.Format("select WareHose_Id,WareHose_Name,WareHose_Address,WareHose_People,WareHose_Phone,WareHose_Remark,Commodity_Url from WareHose where WareHose_Id='{0}'", WareHose_Id);
            return p.ExecDataTable(sql);
        }
        /// <summary>
        /// 修改仓库信息
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public int UpdWareHose(WareHose e)
        {
            string sql = string.Format("update WareHose set WareHose_Name='{0}',WareHose_Address='{1}',WareHose_People='{2}',WareHose_Phone='{3}',WareHose_Remark='{4}',Commodity_Url='{5}' where WareHose_Id='{6}'", e.WareHose_Name, e.WareHose_Address, e.WareHose_People, e.WareHose_Phone, e.WareHose_Remark, e.Commodity_Url, e.WareHose_Id);
            return p.ExecNonquery(sql);
        }
        /// <summary>
        /// 根据仓库名称查询信息
        /// </summary>
        /// <param name="Express_Company_Name">仓库名称</param>
        /// <returns></returns>
        public DataTable SelWareHose(string WareHose_Name)
        {
            string sql = string.Format("select WareHose_Id,WareHose_Name,WareHose_Address,WareHose_People,WareHose_Phone,WareHose_Remark,Commodity_Url from WareHose where WareHose_Name like '%{0}%'", WareHose_Name);
            return p.ExecDataTable(sql);
        }
    }
}
